package cz.gelion.shylock.invoice.web.comp

import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow
import org.apache.wicket.markup.html.panel.Panel
import org.apache.wicket.Component
import org.apache.wicket.ajax.AjaxRequestTarget
import cz.gelion.shylock.invoice.Log


class ModalDataWindow(id:String) extends ModalWindow(id) with Log {

    var close:AjaxRequestTarget => Unit = f
  
	override def getContentId:String = "content"
	  
	def feedback:()=>Component = {
      ()=>getContent.get("feedback")
    }
	  
	override def setContent(c:Component):ModalDataWindow = {
	  var p = new ModalDataPanel(super.getContentId())
	  p.add(c)
	  super.setContent(p)
	  this
	}
  
    setWindowClosedCallback(new ModalWindow.WindowClosedCallback {
      override def onClose(target:AjaxRequestTarget) = {
        log.trace("closing modal");
        //removeAll(); 
        close(target)
        close = f
      }
    })
	
    def f(t:AjaxRequestTarget) = {}
 
}

